<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: jinzhao
 * Date: 16-8-1
 * Time: 下午6:58
 */

class Article_model extends CI_Model{
    public function issue($article)
    {
        return $this->db->insert('article', $article);
    }
    
    public function get()
    {
        $data = $this->db->select('article.aid, type.type, cate.cname, article.title,article.time'
            )->from('article'
            )->join('type', 'article.type=type.id'
            )->join('cate', 'article.cid=cate.cid')->order_by('article.aid', 'asc'
            )->get()->result_array();
        return $data;
    }
    
    public function del($aid)
    {
        $result =  $this->db->delete('article', array('aid' => $aid));
        if ($result){
            if ($this->db->affected_rows() > 0){
                return true;
            }
        }
        return false;
    }
}